package sample.plugin.http.lang;

import com.rapid.api.ext.plugin.AndroidPlugins;
import com.rapid.api.framework.common.icon.IconService;
import com.rapid.api.lang.Language;
import com.rapid.api.lang.factory.LanguageFactory;
import com.rapid.api.project.service.LanguageManager;
import com.rapid.util.android.ContextUtils;

import sample.plugin.http.R;
import sample.plugin.http.lang.engine.RequestCompletionProvider;
import sample.plugin.http.lang.engine.RequestLanguageEngine;

public class RequestLanguageFactory implements LanguageFactory {

    /**
     * 此处使用构造依赖注入，QiStudio初始化本类时会自动注入构造依赖对象
     * 由于LanguageManager作用域分为全局和项目，此处指定从全局装载语言提供器
     */
    public RequestLanguageFactory(LanguageManager languageManager, IconService iconService) {
        languageManager.registerEngine(RequestLanguage.ID, RequestLanguageEngine.getInstance());
        iconService.putFileIcon(
                ContextUtils.getDrawable(
                        AndroidPlugins.getContext(this),
                        R.drawable.ic_http
                ),
                "req"
        );
    }

    @Override
    public String getLanguageId() {
        return RequestLanguage.ID;
    }

    @Override
    public String getAssociateFileType() {
        return "req";
    }

    @Override
    public Language newLanguage() {
        return new RequestLanguage();
    }
}
